home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / public.arc / PKSCRYPT.DOC < prev    next >
Text File  |  1985-12-30  |  10KB  |  186 lines

  1.  
  2.            Public Key System for Encryption and Digital Signatures
  3.  
  4.                        Copyright (c) Lloyd Miller, 1985
  5.                                Calgary, Alberta
  6.  
  7. Public Key Encryption is a  system of encypting messages where  the encryption
  8. and decryption keys are different. The, so called, public encryption key, used
  9. to encrypt messages  is related to  the private decrption  key but it  is very
  10. difficult to figure  out the decyrption  key if you  only know the  encryption
  11. key.
  12.  
  13. To send a secret  message to someone you  need to know only  their public key.
  14. For anyone to send you a secret message, you need to let them know your public
  15. key. I have included  my public key with  these files so that  anyone who gets
  16. this system can send me a secret message (I don't know why they might want  to
  17. but they can). If someone  wants me to reply then  they would have to send  me
  18. their public key.
  19.  
  20. Messages  can  also  be  encrypted  with  the  private  key.  This is called a
  21. signature. Anyone who knows  the public key can  decrypt the message but  only
  22. the  person  who  has  the  corresponding  private  key could have created the
  23. message. I have included a message signed by me in this archive that can  only
  24. be decoded with my private key and  thus could only have been encrypted by  my
  25. private  key.  Signatures  are  not  generally  quite  as useful as the normal
  26. encryption operation but they do have some very interesting capabilities.
  27.  
  28. Messages can be encrypted more than once. One use for this feature is to  sign
  29. a  secret  message.  To  do  this  you  encrypt  the  message  with  both  the
  30. originator's private key and the recipient's public key. The combination is  a
  31. message which only the recipient can  read and only the originator could  have
  32. created. In order  to read the  message it must  be decrypted twice  using the
  33. recipeint's private key and the  originator's public key in the  reverse order
  34. that it was encrypted.
  35.  
  36. The difficulty of "breaking"  the key is dependant  on the length of  the keys
  37. used. Keys  of 8  digits (the  smallest ones  supported by  this package)  are
  38. actually quite easy to break.  I havn't really tried it  but a key of even  50
  39. digits is estimated that  it could be decoded  in about 4 hours  using a super
  40. computer and the fastest  factoring algoritm known. A  key of 75 digits  would
  41. take 104 days and a key of 200 digits would take 3,800,000,000 years. For more
  42. on this see the ACM article.
  43.  
  44. The disadvantage of longer keys is that it takes longer to find and create the
  45. key and the encryption/decryption processes are slower as well. A 8 digit  key
  46. will only take about 1/2 minute  to generate with this software on  a standard
  47. IBM-PC. A 20 digit key takes about 90 sec. A 50 digit key, about 10 min. A 200
  48. digit key will take about 6 to 12 hours. These times may be longer or  shorter
  49. depending on your luck on the random number generator.
  50.  
  51. GENKEYS is a program  to generate encryption and  decryption keys for the  RSA
  52. (Rivest, Shamir, Adleman) system of public key encryption. See  Communications
  53. of the ACM, February, 1978.
  54.  
  55. GENKEYS takes, as  the first input  parameter, a single  number from 8  to 200
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. designating the number  of digits desired  in the key.  This number determines
  68. the level of security of the resulting cypher. It also determins the amount of
  69. time needed to generate a key.
  70.  
  71. Also input  is a  name for  the key  to be  generated. This  is an 8 character
  72. filename without extention.
  73.  
  74. Output of the program  is two files. The  first is the public  key file called
  75. keyname.KEY. It  contains two  numbers, each  of which  contains ,at most, the
  76. number of digits requested. The first number is called "n" and is the  product
  77. of two large prime numbers (p and q). The second number is called "e" and is a
  78. number which  is relativly  prime to  (p-1)*(q-1). These  numbers are  the, so
  79. called, public key. This file is the one to be given out and/or published  for
  80. people who want to send you secret messages.
  81.  
  82. The second file produced is called keyname.KDY. It also has two numbers in it.
  83. The first is  "n" and is  the same as  the "n" in  the public key.  The second
  84. number in this  file is called  "d" and is  the secret decryption  key. "d" is
  85. constructed such that (d * e) MOD ((p -  1) * (q - 1)) = 1. This file  is your
  86. private key for decrypting messages encrypted with your public key and must be
  87. kept secure and private. Perhaps keep it  on a floppy disk and locked up  when
  88. not in use, perhaps with extra copies in separate places.
  89.  
  90. The key files are only significant up to the end of the second number in  them
  91. so comments may be added at the end of the file. This is particularily usefull
  92. for the public key files where the name and/or address can be added to the key
  93. to  indicate  the  owner  of  the  key.  For  an example of this, see the file
  94. LLOYD.KEY included in this archive. That file is my public key and can be used
  95. to send me secret  messages. When you edit  these files make sure  your editor
  96. does not break any long lines into shorter lines. For instance a 200 digit key
  97. would have over  200 characters in  each of the  first two lines.  These lines
  98. must not be broken up into shorter lines.
  99.  
  100. One of the nice features of the  RSA key system is that you can  sign messages
  101. by encrypting them with you private key. Such a message can only be  decrypted
  102. with your public key  and thus proves (so  long as you have  kept your private
  103. key secret) that you have originated the message.
  104.  
  105. Two more programs are included with this system. they are ENCRYPT and DECRYPT.
  106. They use the key files created by GENKEYS to encrypt and decrypt other  files.
  107. The time required for these programs to do their job depends on the length  of
  108. the key used and the size of the file. Any file can be encrypted with any key.
  109. They can only be decrypted with the opposite key of the pair.
  110.  
  111. ENCRYPT, when run will ask  for the name of the  file to be encrypted and  the
  112. full name of the  key file to be  used for encryption (ie  "LLOYD.KEY"). Third
  113. and last it will ask for a file to store the encrypted file in. ENCRYPT  saves
  114. the name of the key file used to  encrypt in the output file in plain text  so
  115. that the decrypt system can easily figure out which key is needed. It does not
  116. store any keys  in the encrypted  file, just the  key file name.  Encrypt also
  117. saves the  input file  name and  size in  the encyrpted  file. This  is so the
  118. decryption can reproduce the origninal file. The input file name and size  are
  119. encrypted  so  no  extra  information  is  obtainable  from the encrypted file
  120. without the decryption key.
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. DECRYPT first asks  for name of  the encrypted file.  It reads the  header and
  134. offers you  the default  name for  the decryption  key. (I.E.  if the file was
  135. encrypted with a key called "test.key" it will ask if you want to decrypt with
  136. "test.kdy".) Normally  you would  anser "yes"  to this  question. If  you have
  137. renamed the key file you want to use  then answer no and type in the name  you
  138. want to use. If you  tell the program the wrong  key to use then nothing  will
  139. work right  after that.  DECRYPT then  decodes the  first part  of the file to
  140. obtain the original file name and  size. Once it has decoded this  information
  141. it will ask you if you want to  use the original name for the decoded file  or
  142. you can  enter your  own name  for the  file to  be created. DECRYPT will then
  143. procede to decrypt the rest of the file.
  144.  
  145.  
  146. Anyone can make  as many copies  of this software  as they want  and give them
  147. away so long as all three programs and this documentation are included in  any
  148. copies and all files  are in their original  unmodified form. In fact  you are
  149. encouraged to distribute this software  as much as possible by  whatever means
  150. you can  find, electronic,  magnetic, optical  or via  any future technologies
  151. which may be developed. If you find this system usefull then you can encourage
  152. me to write and distribute more of my software by sending $30 to:
  153.  
  154.     Lloyd Miller
  155.     2420 Capitol Hill Crescent, N.W.
  156.     Calgary, Alberta    T2M-4C2
  157.  
  158. If you are a corporate or governmental user then the $30 is not optional.
  159.  
  160. This software  and documentaion  is protected  by copyright  and if  you don't
  161. think that means much then ask a lawyer.
  162.  
  163. If you  have comments,  complaints (heaven  forbid) or  questions then you can
  164. either send a SASE to the above address or send a message to me via Fidonet(TM
  165. of Tom Jennings) node 134/1, "The Calgary Fido". If you want to send encrypted
  166. messages via  Fidonet then  you will  need your  sysop's co-operation  to send
  167. "attached files". If you want to send encrypted messages via traditional  mail
  168. then you would have to send floppy disks.
  169.  
  170. This software is  designed to run  on an IBM-PC  using MS-DOS version  2.00 or
  171. later.  I  have  tried  to  avoid  using  any features of the IBM-PC which are
  172. machine dependant so I believe it should work on any system which uses  MS-DOS
  173. or PC-DOS but it has  not been tested on any  other types of systems. I  would
  174. like to hear from  you if you have  tried it on any  other systems and if  you
  175. have had any probelms or not.
  176.  
  177. These programs are written in Modula-2 using the Logitech Modula-2/86 compiler
  178. system. I would be willing to consider converting these programs for use  with
  179. other Modula-2 systems if anyone wants to pay me to do the convertion. I would
  180. not consider converting the programs to another language. The nature of  these
  181. programs  would  probably  eliminate  from  consideration any M-CODE or P-CODE
  182. interpreter style compiler systems since they would become prohibitivly slow.
  183.  
  184.                                                                   Lloyd Miller
  185.                                                               1985 December 30
  186.